#!/bin/bash
echo "------------------------------------------------------------------------------------------"
echo "此脚本用来过滤吉利语音log  @auther 李鹏程 @auther 李鹏程 @auther 李鹏程"
echo "此脚本用来过滤吉利语音log  @auther 李鹏程 @auther 李鹏程 @auther 李鹏程"
echo "此脚本用来过滤吉利语音log  @auther 李鹏程 @auther 李鹏程 @auther 李鹏程"
echo "------------------------------------------------------------------------------------------"

originFilepath=$1

if [ -f $originFilepath ];then
  echo "${originFilepath} is file"
else
  echo "${originFilepath} is not file; And exit"
  exit
fi

echo "--------------`date "+%Y-%m-%d-%H:%M:%S"`-------------------------------------------------"
#tempDate=`date "+%Y-%m-%d-%H:%M:%S"`

namePrefix=${originFilepath##*/}
namePrefix=${namePrefix%.*}
iovbepName=$namePrefix-IOVBEP.log
bdasrName=$namePrefix-BDASR.log
wpasrName=$namePrefix-WPASR.log

cat $originFilepath |grep -E IOVBEP > $iovbepName
cat $iovbepName | awk -v FS=" " '{printf "%d\n",$3}' | while read line
do
  if [[ -z $line ]];then
    echo "文件格式错误"
  else
    cat $originFilepath |grep -E $line > $bdasrName
  fi
  exit
done
cat $iovbepName |grep -E "VrManager|WakeUpEventProcess|AsrResultFilter" > $wpasrName
